let $elem;
function getInstance() {
    if (!$elem) {
        $elem = $('<div class="promptTip"><div class="loading"></div></div>');
        $elem.appendTo('body');
    }
    return $elem;
}

function tip(text, callback, time) {
    getInstance();
    if (text) {
        $elem.show();
        $elem.find('.loading').html(text || '正在加载中...');
        time
            && setTimeout(() => {
                $elem.hide();
                callback && callback();
            }, time);
    } else {
        $elem.hide();
    }
}

export default tip;
